public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
//            System.out.println(Thread.currentThread().getState());
//            for (int i = 0; i < 3; i++) {
//                System.out.println(Thread.currentThread().getName());
//                try {
//                    Thread.sleep(2000);
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                }
//            }
            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
//        System.out.println(thread.getState());//NEW
        thread.start();
//        System.out.println(thread.getState());//RUNNABLE
//        Thread.sleep(1000);
//        System.out.println(thread.getState());//TIMED_WAITING

//        thread.join(10000 * 1000);
//        System.out.println(thread.getState());//TERMINATED
//        System.out.println(thread.getState());
        thread.join();
    }
}
